<!DOCTYPE html>
<%@ page import="java.util.ArrayList, domain.file.FileDetails, constants.Constants" %>
<%
	String userName="";
	if(request.getSession().getAttribute("name")!=null) {
		userName=request.getSession().getAttribute("name").toString();		
	}
	ArrayList<FileDetails> userScenarioList = new ArrayList<FileDetails>();
	if(request.getSession().getAttribute(Constants.SESSION_USER_SCENARIO_LIST)!=null){
		userScenarioList = (ArrayList<FileDetails>) request.getSession().getAttribute(Constants.SESSION_USER_SCENARIO_LIST);
	}
	
	ArrayList<FileDetails> allScenarioList = new ArrayList<FileDetails>();
	if(request.getSession().getAttribute(Constants.SESSION_ALL_SCENARIO_LIST)!=null){
		allScenarioList = (ArrayList<FileDetails>) request.getSession().getAttribute(Constants.SESSION_ALL_SCENARIO_LIST);
	}
	
	ArrayList<FileDetails> analyzedScenarioList = new ArrayList<FileDetails>();
	//if(request.getSession().getAttribute(Constants.SESSION_ANALYZED_SCENARIO_LIST)!=null){
	//	analyzedScenarioList = (ArrayList<FileDetails>) request.getSession().getAttribute(Constants.SESSION_ANALYZED_SCENARIO_LIST);
	//}
	if(request.getSession().getAttribute(Constants.SESSION_ALL_SCENARIO_LIST)!=null){
		analyzedScenarioList = (ArrayList<FileDetails>) request.getSession().getAttribute(Constants.SESSION_ALL_SCENARIO_LIST);
	}
%>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My DairyVIP</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
    <meta name="description" content="">
    <meta name="author" content="">
  
    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <link href="../css/bootstrap-responsive.css" rel="stylesheet">
     <link href="../css/docs.css" rel="stylesheet">

    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    
    
    
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
	  label.error {color:red}
 #progress { 
                display: none;
            }
       
    </style>
<script>
function OperaReload() {
try {
var headElement = document.getElementsByTagName("head")[0];
if (headElement && headElement.innerHTML)
headElement.innerHTML += "<meta http-equiv=\"refresh\" content=\"1\">";
}
catch (e) {}
}
</script>   

    
   
  </head>

<body onUnload="OperaReload()">
<div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
        <a class="brand" href="#">DairyVIP</a>
          <div class="nav-collapse collapse">
            <p class="navbar-text pull-right">Logged in as <%= userName %>
            </p>
            <ul class="nav">
              <li><a href="index.jsp">Home</a></li>
     <li><a href="../jsp/acknowledgements_contro.jsp">Acknowledgements/Contributors</a></li>
    <li class="active"><a href="#">My DairyVIP</a></li>
 <li><a href='../jsp/logoff'>Log Off</a></li>
	
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>

<div class="container">
          <div class="hero-unit">
            <img src="../images/new-header2.jpg" alt="bg3"  class="img-polaroid" />
          </div>
          
          <div class="row-fluid">
          
          
          
		<div class="span4">
          <p>&nbsp;</p>
<div class="well  well-small">
<form id="createScenario" name="createScenario" action="../jsp/createScenario" method="post">

    <legend>Create/Clone Scenario </legend>

    <select name="createScenarioId" id="createScenarioId">
    
     					<% for(int i = 0;i< allScenarioList.size();i++)   
						{ %> <option value ="<%= allScenarioList.get(i).getFileNo() %>">  
						<%=(String)allScenarioList.get(i).getFileName() %></option>  
						<%} %>
				</select>
    <p></p>
 
    <!--<label>New Name of Scenario</label>-->
    <input type="text" placeholder="New Name of Scenario" id="newFileName" name="newFileName"  class="required" />
  <!-- <label>Description of Scenario</label>-->
    <input type="text" placeholder="Description of Scenario" id="newFileDescription" name="newFileDescription" class="required" />
   <br>
   <input class="btn" type="submit" value="Create"  />    
 
 
 
 
 
 
    </form>
  </div>
</div><!--/span-->


           <div class="span4">
              <p>&nbsp;</p>
            <div class="well  well-small">
              <form name="deleteScenario" method="post">
    <legend>Edit/Analyze/Delete Scenario</legend>
  
    <select id="deleteScenarioId" name="deleteScenarioId">
						<% for(int i = 0;i< userScenarioList.size();i++)   
						{ %> <option value ="<%= userScenarioList.get(i).getFileNo() %>">  
						<%=(String)userScenarioList.get(i).getFileName() %></option>  
						<%} %>
				</select>
    
    <br>
 <input class="btn" type="button" value="Edit Scenario" onClick="editScn(this.form)" />
<a href="#myModal" data-toggle="modal"><input id="deletescenario" class="btn" type="button"  value="Delete Scenario" /></a> 
<!-- Modal -->
<div id="myModal" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4>Confirmation</h4>
</div>
<div class="modal-body">

<p>Are you sure to delete this scenario?</p></div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button class="btn btn-primary"  onclick="deleteScn(this.form)">Yes</button>

</div>
</div><!--modal-->
    </form>
    </div><!--well-->
    </div><!--/span-->

<div class="span4">
             <p>&nbsp;</p>
            <div class="well  well-small">
             <form name="selectScenario" method="post">
              <legend>Show Results </legend>
              <select name="selectScenarioId1">
						<% for(int i = 0;i< analyzedScenarioList.size();i++)   
						{ %> <option value ="<%= analyzedScenarioList.get(i).getFileNo() %>">  
						<%=(String)analyzedScenarioList.get(i).getFileName() %></option>  
						<%} %>
				</select>
				<select name="selectScenarioId2">
						<% for(int i = 0;i< analyzedScenarioList.size();i++)   
						{ %> <option value ="<%= analyzedScenarioList.get(i).getFileNo() %>">  
						<%=(String)analyzedScenarioList.get(i).getFileName() %></option>  
						<%} %>
				</select> 
        
 <br>           
				
				
					<input class="btn" type="button" onclick="resultScn(this.form)" value="Show Results" />   
           
 </form>
<!-- <img src="../images/ajax-loader-bar.gif" id="progress" style="display: none"/>	-->
 
    <!-- <div class="progress progress-striped active" id="progress" style="display: none; width: 80%;">
    <div class="bar" style="width: 100%;"><strong>Simulating</strong></div>-->
 <p id="foo" align="center" style="display:none; width=100%;  margin-top:40px"></p>
    </div>

 </div>
</div>

</div>

    
      <footer class="footer">
       <%@ include file="../inc/footer.html" %>
      </footer>

    </div><!--/.fluid-container-->

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    
  <script type="text/javascript" src="../js/jquery.js"></script>
  <script src="../js/bootstrap.js"></script>
<script type="text/javascript" src="../js/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="../js/jquery.color.js"></script>
<script type="text/javascript" src="../js/placeholder.js">
</script>
<script type="text/javascript" src="../js//jquery.validate.js"></script>
<script type="text/javascript" src="../js/spin.js">
</script>

<script>
 $(document).ready(function(){
 $("#createScenario").validate( {
		onfocusout:true		}	);

                });

</script> 

    <script language="javascript">
			function editScn(form)/*function to check userid & password*/
			{
				
			form.action = '../jsp/editScenario';
			form.submit();
			//var x=document.getElementById("deleteScenarioId").selectedIndex;
			//var fileNo_value=document.getElementsByTagName("option")[x].value;
			//page = "../jsp/inputMisc" + "?fileNo="+fileNo_value;
			//window.self.location.href = page;
			return true;
			}
			function resultScn(form)
			{
			ShowProgress() ;	
			form.action = '../jsp/showResult';
			form.submit();
			return true;
			}
			
			function ShowProgress() {
				var opts = {
  lines: 13, // The number of lines to draw
  length: 7, // The length of each line
  width: 4, // The line thickness
  radius: 24, // The radius of the inner circle
  corners: 0.3, // Corner roundness (0..1)
  rotate: 36, // The rotation offset
  color: '#000', // #rgb or #rrggbb
  speed: 1.5, // Rounds per second
  trail: 87, // Afterglow percentage
  shadow: false, // Whether to render a shadow
  hwaccel: false, // Whether to use hardware acceleration
  className: 'spinner', // The CSS class to assign to the spinner
  zIndex: 2e9, // The z-index (defaults to 2000000000)
  top: 'auto', // Top position relative to parent in px
  left: 'auto' // Left position relative to parent in px
};
var target = document.getElementById('foo');
var spinner = new Spinner(opts).spin(target);
				 
   target.style.display = 'block';
     
   }


			
			function deleteScn(form)/*function to check userid & password*/
			{
			form.action = '../jsp/deleteScenario';
			form.submit();
			//page = "../jsp/result" + ".jsp";
			//window.self.location.href = page;
			return true;
			}
			
			/*jQuery.validator.addMethod( 
	  "selectNone", 
	  function(value, element) { 
	    if (element.value == "none") 
	    { 
	      return false; 
	    } 
	    else return true; 
	  }, 
	  "Please select a scenario." 
	); */
/*	$(document).ready(function() { 
	  $("#createScenario").validate({ 
	    rules: { */
/*	      createScenarioId: { 
	        selectNone: true 
	      },*/
/*		   newFileName: {
            required: function() {
                return $("[name='createScenarioId']").val() == 'nothing';
            }
        },
		
        newFileDescription: {
            required: function() {
                return $("[name='createScenarioId']").val() == 'nothing';
            }
        }
		  
	    },
		 
	  }); 
	}); */
		</script>   

  </body>
</html>
